package com.idrl.servlet;

import java.util.Properties;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;
import org.apache.velocity.app.Velocity;

import com.idrl.utils.Global;



public class InitServlet extends HttpServlet 
{
	private static Logger log = Logger.getLogger(InitServlet.class);
	
    public void init(ServletConfig config) throws ServletException
	{
    	super.init();
    	Global.CONTEXT_REAL_PATH = config.getServletContext().getRealPath("/");    	
    	
    	try {
            Properties p = new Properties();   
            p.setProperty("resource.loader", "class");   
            p.setProperty("class.resource.loader.class",    
                "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");   
            p.setProperty("input.encoding", "UTF-8");   
            Velocity.init(p); 
		} catch (Exception e) {
			log.error("velocity", e);
		} 
    }
}
